package com.arron.myhash;

/**
 * @Classname Person
 * @Date 2020/9/4 13:26
 * @Created by 刘
 */
public class Person {

    private Integer uid;
    private String name;

    public Person(Integer uid, String name) {
        this.uid = uid;
        this.name = name;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null){
            throw new RuntimeException("参数不能为null");
        }

        if (obj instanceof Person){
            Person p = (Person) obj;
            if (p.getUid()==this.getUid() && p.getName().equals(this.getName())){
                return true;
            }
            return false;
        }else {
            throw new RuntimeException("传入的参数错误");
        }
    }

    @Override
    public int hashCode() {

        int result = this.getUid();
        result = result*31 + this.getName().hashCode();
        return result;
    }

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
